using System;
using System.Collections.Generic;
using System.Text;
using IReaper.FileData;
using IReaper.Statues;
using System.ComponentModel;

namespace IReaper.Command
{
    class DownloadFileCommand:CommandBase
    {
        public override CommandFamily Family
        {
            get { return CommandFamily.Command_DownloadFile; }
        }

        public override void CommandBody(object sender, params object[] paras)
        {
            if (paras == null || paras.Length < 1)
                return;
            IList<CourseFileData> Files = paras[0] as IList<CourseFileData>;
            if (Files == null)
                return;
            Running.DownloadEngine.PauseDownloadEngine(false);
            //remove file in each 
            CourseFileData cfd = null;
            for (int i = 0; i < Files.Count;i++)
            {
                try
                {
                    cfd = Files[i];
                   if (cfd == null)
                       continue;
                   //int percentage = (int)(i * 100 / Files.Count);
                   IReaper.Running.DownloadEngine.AddCourseFileData(cfd);
                }
                catch
                { }
            }
            Running.DownloadEngine.ResumeDownloadEngine();
        }
    }
}
